import Vue from 'vue'
import VueRouter from 'vue-router'
import Index from '../views/index.vue'
import Showlist from 'components/show-list/show-list.vue'
import Personality from 'components/personality/personality.vue'
import Songsheet from 'components/song-sheet/song-sheet.vue'
import Radio from 'components/radio/radio.vue'
import Ranklist from 'components/rank-list/rank-list.vue'
import Singer from 'components/singer/singer.vue'
import Latest from 'components/latest/latest.vue'
import Nav from 'components/nav.vue'

const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (location) {
  return originalPush.call(this, location).catch(err => err)
}
Vue.use(VueRouter)
const routes = [{
  path: '/',
  name: 'index',
  component: Index,
  children: [{
    path: 'nav',
    name: '导航',
    component: Nav,
    children: [{
      path: 'personality',
      name: '个性推荐',
      component: Personality
    },
    {
      path: 'songsheet',
      name: '歌单',
      component: Songsheet,
      meta: {
        keepAlive: true
      }
    },
    {
      path: 'radio',
      name: '主播电台',
      component: Radio,
      meta: {
        keepAlive: true
      }
    },
    {
      path: 'ranklist',
      name: '排行榜',
      component: Ranklist,
      meta: {
        keepAlive: true
      }
    },
    {
      path: 'singer',
      name: '歌手',
      component: Singer,
      meta: {
        keepAlive: true
      }
    },
    {
      path: 'latest',
      name: '最新音乐',
      component: Latest,
      meta: {
        keepAlive: true
      }
    }
    ]
  },
  {
    path: '/showlist',
    name: 'showlist',
    component: Showlist
  }]
}
]

const router = new VueRouter({
  routes
})

export default router